---
title: "Table A.7"
output: html_notebook
---

# Table A.7

# Who's to Blame? Postconflict Violence and Public Attitudes Towards Peace Agreements
# Wyer, Frank. 

#clear environment
```{r clear environment}
rm(list = ls())
```

# uncomment and set working directory to replication archive
# setwd("~/blame_replication")

# Uncomment to install packages if necessary
# install.packages("tidyverse")
# install.packages("xtable")

#load packages
```{r}
library(tidyverse)
library(xtable)
```

#read in data
```{r}
survey_clean <- read.csv("survey_clean.csv")
```

#generate summary statistics
```{r}
summary_stats <- survey_clean %>% dplyr::select(treatment, `Female (1,0)` = female, `Ethnic Minority (1,0)` = eth_minority, `Religious Minority (1,0)` = relig_minority, `Age Cohort (1-6)` = Q15, `Education Level (0-9)` = education_level, `SES Scale` = ses_zscale, `Ideology (1-6)` = Q25, `Engagement Scale` = engage_zscale, `Municipal Homicide Rate` = homrate100k, `Change in Municipal Homicide Rate` = homratediff) %>%
group_by(treatment) %>% 
  summarise(across(1:10, ~ mean(.x, na.rm = TRUE))) %>%
  pivot_longer(cols=c(-treatment),names_to="Original_Vars") %>% 
  pivot_wider(names_from=c(treatment)) %>%
  dplyr::rename(Variable = Original_Vars, `Control Condition` = "C", `Postconflict Violence Condition` = T1, `Government Culpability Condition` = T2A, `Rebel Culpability Condition` = T2B)
```

#generate table
```{r}
summary_stats %>% xtable(digits = 2) %>% print(include.rownames=FALSE)
```
